/*
 * @Description: 你的代码我的心
 * @Author: GGB
 * @Date: 2021-12-27 09:57:24
 * @LastEditors: GGB
 * @LastEditTime: 2022-01-25 09:58:05
 */

import { FormSchema } from '/@/components/Table';

// 库存输入框
export const formSchemas: FormSchema[] = [
  {
    field: 'store_name',
    component: 'Input',
    label: '商城名称',
    colProps: {
      span: 24,
    },
    rules: [{ required: true, min: 3, message: '请输入至少3个字符' }],
    componentProps: {
      placeholder: '请输入商城名称',
    },
  },
  {
    field: 'user_name',
    component: 'Input',
    label: '商家用户名',
    colProps: {
      span: 24,
    },
    rules: [{ required: true, min: 4, message: '请输入至少4个字符' }],
    componentProps: {
      placeholder: '请输入商家用户名',
    },
    helpMessage: '商家后台登录用户名',
  },
  {
    field: 'password',
    component: 'Input',
    label: '用户密码',
    colProps: {
      span: 24,
    },
    rules: [{ required: true, min: 6, message: '请输入至少6个字符' }],
    componentProps: {
      placeholder: '请输入用户密码',
    },
    helpMessage: '商家后台登录密码',
  },
  {
    field: 'password_confirm',
    component: 'InputPassword',
    label: '确认密码',
    colProps: {
      span: 24,
    },
    componentProps: {
      placeholder: '请确认密码',
    },
    rules: [{ required: true, min: 6, message: '请输入至少6个字符' }],
    dynamicRules: ({ values }) => {
      const isEqual = values.password_confirm === values.password;
      return [
        {
          required: true,
          validator: () => (!isEqual ? Promise.reject('两次密码不一致') : Promise.resolve()),
          trigger: ['change', 'blur'],
        },
      ];
    },
  },
  {
    field: 'sort',
    component: 'Input',
    label: '排 序',
    colProps: {
      span: 24,
    },
    rules: [{ required: true }],
    defaultValue: 100,
    componentProps: {
      placeholder: '请输入账号',
    },
    helpMessage: '数字越小越靠前',
  },
];
